//
//  CAUpgradeGoodsCollectionViewCell.m
//  LNH
//
//  Created by twentylx on 2018/2/13.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAUpgradeGoodsCollectionViewCell.h"

@implementation CAUpgradeGoodsCollectionViewCell

- (instancetype) initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.goodsImageView];
        [self addSubview:self.selectedImageView];
        [self addSubview:self.invitePriceLabel];
        [self addSubview:self.priceLabel];
        
        [_goodsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.top.equalTo(self);
            make.height.mas_equalTo(100);
        }];
        
        [_selectedImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.goodsImageView);
            make.bottom.equalTo(self.goodsImageView);
        }];
        
        [_invitePriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.top.equalTo(self.goodsImageView.mas_bottom).offset(20);
        }];
        
        [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.top.equalTo(self.invitePriceLabel.mas_bottom).offset(5);
        }];
        
    }
    return self;
}

- (UIImageView *)goodsImageView {
    if (!_goodsImageView) {
        _goodsImageView = [UIImageView new];
        _goodsImageView.image = LMImageNamed(@"goods");
        _goodsImageView.layer.borderWidth = 1;
    }
    return _goodsImageView;
}

- (UIImageView *)selectedImageView {
    if (!_selectedImageView) {
        _selectedImageView = [UIImageView new];
        _selectedImageView.image = LMImageNamed(@"address_default");
        _selectedImageView.hidden = YES;
    }
    return _selectedImageView;
}

- (UILabel *)invitePriceLabel {
    if (!_invitePriceLabel) {
        _invitePriceLabel = [UILabel new];
        _invitePriceLabel.text = @"上级推荐码：399元";
        _invitePriceLabel.font = [UIFont systemFontOfSize:14];
    }
    return _invitePriceLabel;
}

- (UILabel *)priceLabel {
    if (!_priceLabel) {
        _priceLabel = [UILabel new];
        _priceLabel.text = @"上级推荐码：399元";
        _priceLabel.font = [UIFont systemFontOfSize:14];
    }
    return _priceLabel;
}

@end
